#pragma once 
#include <iostream>
#include<pthread.h>
#include "Mutex.hpp"
using namespace std;

namespace MyCondModule
{
    class Cond
    {   
    public:
        Cond(Mutex& mutex):_mutex(mutex){
            int n = pthread_cond_init(&_cond,nullptr);
            (void)n;
        }
        void Wait(){
            int n = ::pthread_cond_wait(&_cond,_mutex.GetLockPtr());
            (void)n;
        }
        void NotifySignal(){
            int n = ::pthread_cond_signal(&_cond);
            (void)n;
        }
        void NotifyAll(){
           int n = ::pthread_cond_broadcast(&_cond);
            (void)n;
        }
        ~Cond(){
            int n = ::pthread_cond_destroy(&_cond);
            (void)n;
        }
    private:
        pthread_cond_t _cond;
        Mutex& _mutex;
    };
}